<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

//
include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'module/member/member.status.class.php');
$msObj = new MemberStatusBase();
$msObj->notify = true;

//
if( $action == 'updatestatus' ) {
	$msObj->setType($_POST['type']);
	//
	$vObj = new CommonValidate();
	$vObj->checkNull($_POST, array('name'));
	if( $vObj->_valid() ) {
		foreach($_POST as $k => $v) {
			if( substr($k, 0, strlen('field_')) == 'field_' ) {
				$data_array[$k] = $v;
			}
		}
		$msObj->updateItem($data_array);
		//
		_dms(':member:success');
		//
		$feObj->redirect($request_link_current, 's');
	} else {
		$GLOBALS['_SUBMITTED_'] = 1;
		
		$vm = $vObj->_result(':error');
		$injectObj->addb('func_get_tpl_pagelayout_content', 'content_wrap', 'vm', $vm);
	}
}

//
$member = $memberObj->getCurrentUser();
$feObj->addContent('member', $member);

//
if( in_array($request_link_subclass, array('edit', 'edit_basic', 'edit_insure', 'edit_fee', 'edit_live', 'edit_school', 'edit_service')) ) {
	$feObj->addContent('mainpart', $request_link_subclass);
	if( substr($request_link_subclass, 0, 5) == 'edit_' ) {
		$item = $msObj->setType(substr($request_link_subclass, 5));
		$item = $msObj->getItem();
		$items = $msObj->getItems();
		$feObj->addContent('item', $item);
		$feObj->addContent('items', $items);
	}
} elseif( in_array($request_link_subclass, array('detail', 'basic', 'insure', 'fee', 'live', 'school', 'service')) ) {
	$feObj->addContent('mainpart', $request_link_subclass);
	if( $request_link_subclass != 'detail' ) {
		$item = $msObj->setType($request_link_subclass);
		$item = $msObj->getItem();
		$items = $msObj->getItems();
		$feObj->addContent('item', $item);
		$feObj->addContent('items', $items);
	}
}

//
echo $feObj->display('pagelayout/pagelayout_member_status.tpl');
//
?>